using System;
using System.Collections.Generic;
using System.Text;

namespace GoogleNet
{
    /// <summary>
    /// Associates a key to a styleUrl.
    /// </summary>
    public class KmlPair : IKmlElement 
    {
        private string tagName = "Pair";

        #region Key
        private string key;

        /// <summary>
        /// Gets or sets the key.
        /// </summary>
        /// <value>The key.</value>
        public string Key
        {
            get { return key; }
            set { key = value; }
        }
        #endregion

        #region StyleUrl
        private Uri styleUrl;

        /// <summary>
        /// URI (a URI equals [URL]#ID) for the referenced style, defined in a Document. 
        /// If the style is in the same file, use a # reference. 
        /// If the style is defined in an external file, use a full URL along with # referencing.
        /// </summary>
        /// <value>The style URL.</value>
        public Uri StyleUrl
        {
            get { return styleUrl; }
            set { styleUrl = value; }
        }
        #endregion

        #region IKmlElement Members

        /// <summary>
        /// Name of the KML tag for this specific element.
        /// </summary>
        /// <value></value>
        /// <returns></returns>
        public string TagName
        {
            get { return TagName; }
        }

        #endregion

        #region IKmlGenerator Members

        /// <summary>
        /// Generates the KML for this element including its child elements.
        /// </summary>
        /// <param name="writer">The XML writer that will be used to generate the KML.</param>
        public void GenerateKml(System.Xml.XmlTextWriter writer)
        {
            writer.WriteStartElement(tagName);
            writer.WriteElementString("key", key);
            writer.WriteElementString("stylUrl", styleUrl.ToString());


            writer.WriteEndElement();
        }

        #endregion
    }
}
